import service from "./index.js";
import qs from "qs";

const userApi = {
    //注册
    reg(userInfo){
        return service.post("/user/reg", qs.stringify(userInfo));
    },
    //登录
    login(userInfo){
        return service.post("/user/login", qs.stringify(userInfo));
    },
    //验证码
    captcha() {
        return service.get("/user/captcha");
    },
    //分页搜索
    selectByCondition(condition, pageNum, pageSize) {
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/user/selectByCondition", {
            params: condition
        });
    },
    // 根据id查询
    selectById(id) {
        return service.get(`/user/selectById/${id}`);
    },
    //禁用
    disableById(id) {
        return service.post(`/user/disable/${id}`);
    },
    //获取用户信息
    getInfo(){
        return service.get("/user/info");
    },
    //修改个人信息
    update(user) {
        return service.put("/user/update", user);
    },
    //修改密码
    updatePassword(info) {
        return service.put("/user/updatePassword", qs.stringify(info));
    },
    //修改支付密码
    updatePayPassword(info) {
        return service.put("/user/updatePayPassword", qs.stringify(info));
    }
}

export default userApi;